
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>设备维修</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <link rel="stylesheet" href="/lims/css/eleTree.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <style>
        .mbox{
            padding: 8px;
        }
        .layui-btn{
            margin-left: 10px;
        }
        .layui-btn .layui-icon{
            margin-right: 0px;
        }
        .layui-form-label{
            padding: 8px 15px;
        }
        .layui-card-body{
            display: flex;
        }
        .layui-lf{
            min-width: 16%;
            overflow-x: auto;
            height: 600px !important;
        }
        .layui-rt{
            width: 100%;
            margin-left: 6px;
            margin-top: -10px;
        }
        .treeTitle{
            display: flex;
            box-sizing: border-box;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 30px;
            background-color: #00a0e9;
            color: #fff;
            padding: 15px;
            position: relative;
        }
        .layui-nav-item,.layadmin-flexible{
            position: absolute;
            left: 5px;
            top: 23px;
            z-index: 9999999;
        }
        .rtfix{
            width:200px;
            overflow-x: scroll;
        }
        .bg{
            background-color: #F2F2F2;
        }
        .bgs{
            background-color: #F2F2F2;
        }
        .back{
            background-color: #ccc;
        }
        .eleTree{
            cursor: pointer;
        }
        .layui-table-view .layui-table td, .layui-table-view .layui-table th{
            padding: 3px 0;
        }
        .layui-tab-title{
            height: 30px;
        }
        .layui-tab-title li{
            height: 36px;
            margin-top: -5px;
        }
        .layui-tab layui-tab-card{
            margin-top: -4px;
        }
        .layui-tab-card>.layui-tab-title .layui-this:after {
            border-width: 0px;
        }
        .baseinfo td{
            padding: 5px 2px;
        }
        .back{
            background-color: #F2F2F2;
        }
    </style>
</head>
<body>

<div class="mbox">

    <div class="layui-card">
        <div class="layui-card-body" style="padding-left: 6px;">
            <div style="position: relative" class="layui-rt">
                <table id="Settlement" lay-filter="SettlementFilter"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbar">
    <%--搜索--%>
    <div class="layui-form demoTable" style="display: inline-block;position: absolute;margin-top: 12px;">
        <div class="layui-form-item">
            <div class="layui-inline" style="margin-top: -28px; margin-left: 50px;">
                <label  class="layui-form-label" style="width: 86px;margin-top: 9px;">查询字段</label>
                <div class="layui-input-inline" style="height: 27px;margin-top: 6px;" >
                    <select class="layui-select"  lay-filter="cloum" name="cloum" id="cloum" autocomplete="off" style="margin-top: -5px">
                        <option placeholder="请选择"></option>
                        <option value="EQUIP_NO">设备编号</option>
                        <option value="EQUIP_NAME">设备名称</option>
                        <option value="EQUIP_STATUAS_CODE">设备状况</option>
                        <option value="MODEL_NO">型号</option>
                        <option value="SPEC">规格</option>
                        <option value="MANUFACTURER">生产厂家</option>
                        <option value="SUPPLIER">供应商</option>
                        <option value="PROPERTY_CODE">产权归属</option>
                        <option value="FACTORY_NO">出厂编号</option>
                    </select>
                </div>
                <div class=" layui-input-inline"  style="width: 150px;padding-top:5px;box-sizing: border-box">
                    <input type="text" name="price_max" id="fieldVal" placeholder="请输入" autocomplete="off" class="layui-input" style="margin-top: 1px;width:180px;">
                </div>
                <div class="layui-input-inline" style="width: 55px;margin-left: 38px">
                    <button id="search" class="layui-btn layui-btn-sm" data-type="reload" lay-event="serch"  style="height: 35px;line-height: 35px;margin-top:8px;width: 70px;">搜索</button>
                </div>
            </div>
        </div>

    </div>
</script>

<script type="text/html" id="toolbars">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" href="/equipCert/addvice">新增</button>
        <button class="layui-btn layui-btn-sm" lay-event="pedit" style="width: 70px">批量修改</button>
    </div>
</script>
<script type="text/javascript">

    var el
        ,aldata
        ,newstr='<div class="iptbox mnodec" pid="">'+
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="序号" class="layui-input pnul">'+
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="名称" class="layui-input shorts">'+
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="备注" class="layui-input longs">'+
        '<div class="btnls">'+
        '<button type="button" class="layui-btn layui-btn-primary layui-btn-sm limsAdd"><i class="layui-icon"></i></button>'+
        '<button type="button" class="layui-btn layui-btn-primary layui-btn-sm limsDel"><i class="layui-icon"></i></button>'+
        '</div>'+
        '</div>';
    var resultTypeData='';
    var a ="";
    var name;
    var pid;
    var idkey;
    var lables;
    var equipIds= parent.equipIds   //调取父页面的下拉树id;
    var equipId;
    var equipStatuasId    //状态的id
    $('.rtfix').css('max-height',autodivheight()-55)
    var tableObj;
    layui.use(['table','layer','form','element','eleTree'], function(){
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        var eleTree = layui.eleTree;
        var element = layui.element;
        var $ = layui.jquery;
        var url='/equipment/deleteEquipment';
        tableObj = layui.table.render({
            elem: '#Settlement'
            , data: []
            , url: '/equipment/selectAllEquipment?equipTypeId=' + equipIds //数据接口
            , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['prev', 'page', 'next', 'skip', 'count', 'limit',]//自定义分页布局
                , limits: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
                , first: false //不显示首页
                , last: false //不显示尾页
            } //开启分页
            , toolbar: '#toolbar'
            , cols: [[ //表头
                {type: 'checkbox'}
                , {field: 'equipNo', title: '设备编码'}
                , {field: 'equipName', title: '设备名称', sort: true}
                , {field: 'equipStatuasId', title: '设备状况'}
                , {field: 'modelNo', title: '型号'}
                , {field: 'spec', title: '规格'}
                , {field: 'manufacturer', title: '生产厂家'}
                , {field: 'supplier', title: '供应商'}
                , {field: 'propertyId', title: '产权归属'}
                , {field: 'factoryNo', title: '出场编号'}
            ]]
            , limit: 5
            , done: function (res) {

                if (res.msg == "查询无数据") {
                    $('.layui-table-page').hide()
                }
                $.get('/equipmentCapys/selectByEquipId', {equipId: res.data[0].equipId}, function (res) {
                    resultTypeData = res.data;
                    var str = "";
                    for (var i = 0; i < resultTypeData.length; i++) {
                        str += '<tr>' +
                            '<td style="color: #111;">' + resultTypeData[i].capyName + '</td>' +
                            '<td idx="' + i + '" typename="capyInitialValue" class="edit" style="color: #111;">' + undefind_nullStr(resultTypeData[i].capyInitialValue) + '</td>' +
                            '<td idx="' + i + '" typename="calibrationValue"  class="edit" style="color: #111;">' + undefind_nullStr(resultTypeData[i].calibrationValue) + '</td>' +
                            '</tr>';
                    }
                    $(".total").html(str)
                    layui.form.render();
                })
            }
        });


       //监听复选框事件
        table.on('checkbox(SettlementFilter)', function(obj){
            equipStatuasId = obj.data.equipStatuasId
            equipId = obj.data.equipId
        });

        // 初始化渲染 树形菜单
        // el = eleTree.render({
        //     elem: '.ele1',
        //     showLine:true,
        //     url:'/equipmentType/showParentEquipmentType',
        //     lazy: true,
        //     load: function(data,callback) {
        //         $.post('/equipmentType/showChildEquipmentType?equipTypeId='+data.id,function (res) {
        //             callback(res.data);//点击节点回调
        //         })
        //     },
        //     done:function (data) { //渲染完成回调
        //         aldata = data.data
        //         name=data.data[0].name //传的是默认选中的值
        //         pid = data.data[0].equipTypePid;
        //         getTabke(data.data[0].id);
        //         var dataid=$('.ele1 div').attr("data-id")
        //         $('.eleTree-node').removeClass('back')
        //         $('.ele1 div[data-id='+dataid+']').addClass('back')
        //         $('.eleTree-node-group').css('background','#fff')
        //     }
        // });

        // 节点点击事件
        // eleTree.on("nodeClick(data1)",function(d) {
        //        //     lables = d.data.currentData.label   //获取下拉树的名字
        //        //     var dataid=$('.ele1 div').attr("data-id")
        //        //     var a = d.data.currentData.id;
        //        //     $('.eleTree-node').removeClass('back')
        //        //     $(d.node[0]).addClass('back')
        //        //     $('.eleTree-node-group').css('background','#fff')
        //        //     var obj = d.data.currentData
        //        //     name = obj.name
        //        //     pid = obj.equipTypePid;
        //        //     idkey = obj.id;
        //        //     $.post('/equipmentType/showEquipmentTypeById?equipTypeId=' + obj.id, function (res) {
        //        //         equipids = res.object.id   // 节点下拉数的id
        //        //         var obj = res.data
        //        //             , str;
        //        //     })
        //        //     var currentPage = 1
        //        //     table.reload('Settlement',{
        //        //         url : '/equipment/selectAllEquipment?equipTypeId='+obj.id,
        //        //         data:{page:currentPage},
        //        //         page:{
        //        //             curr:currentPage
        //        //         }
        //        //     })
        //        // });
// 编辑/删除操作
        table.on('tool(SettlementFilter)', function(obj){//注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            var equipId= data.equipId;
            var urlTitle='/equipment';
            if(layEvent === 'del'){ //删除
                // layer.confirm('确认删除', function(index){
                publicDelete(urlTitle+"/deleteEquipment",equipId+"",tableObj,table);
                //向服务端发送删除指令
                // });
            }
        });

        table.on('toolbar(SettlementFilter)',function(obj){//根据下拉字段模糊查询设备
           var eve =  obj.event;
           var fieldName=$("#cloum").val();
           var fieldValue=$("#fieldVal").val()
           if(eve=='serch'){
               tableObj.reload({
                   page:true,
                   url:'/equipment/selectEquipByField',
                   where:{
                       fieldName:$("#cloum").val(),
                       fieldValue:$("#fieldVal").val(),
                       equipTypeId:equipIds
                   }
                   ,done:function(res){
                        $("#cloum").val(fieldName)
                        $("#fieldVal").val(fieldValue)
                       layui.form.render('select');
                   }
               })
           }
        })
    });
    //将毫秒数转为yyyy-MM-dd格式时间
    function format(t) {
        var  str = "";
        var nnow = new Date(t);
        var year = nnow.getFullYear();
        var month = nnow.getMonth()+1;
        var day = nnow.getDate();
        str = year+"-"+month+"-"+day;
        return str;
    }
    //获取当前时间  年月日
    function nowformat() {
        var  nstr = "";
        var now = new Date();
        var nyear = now.getFullYear();
        var nmonth = now.getMonth()+1;
        var nday = now.getDate();
        if(nmonth<10){
            nmonth = "0"+nmonth;
        }
        if(nday<10){
            nday = "0"+nday;
        }
        nstr = nyear+"-"+nmonth+"-"+nday;
        return nstr;
    }
    $("#equip").click(function(){
        window.location.reload()
    })
    // $('#fixed').click(function(e){
    //     e.stopPropagation();
    //     $('table').width('100%')
    //     if($(this).attr('dataType')!=1){
    //         $('.layui-lf').fadeOut();
    //         $('.layui-rt').animate({width: '100%'});
    //         $(this).attr('dataType','1');
    //     }else{
    //         $('.layui-lf').fadeIn();
    //         $('.layui-rt').animate({width: '84%'});
    //         $(this).attr('dataType','0');
    //     }
    //
    // })



    // 子页面数据传向父页面
    // function getData() {
    //     equipId =layui.table.checkStatus('Settlement').data.
    //     return equipId;
    // };
    function undefind_nullStr(value) {
        if(value==undefined){
            return ""
        }
        return value
    }
</script>
</body>



</html>